package com.handinglian.task.enums;

public enum TaskStateEnum {
    UNKNOWN(0,""),
    EXECUTORY(1,"执行中"),
    READY_START(2,"待开始"),
    OVERDUE(3,"已过期"),
    READY_ASSIGN(4,"待分配");

    public static TaskStateEnum valueOfOrdinal(Integer ordinal) {
        return ordinal == null || ordinal >= values().length ? UNKNOWN : values()[ordinal];
    }
    public static TaskStateEnum valueOfDesc(String desc) {
        for(TaskStateEnum taskStateEnum: TaskStateEnum.values()){
            if(desc.equals(taskStateEnum.getDescription())){
                return taskStateEnum;
            }
        }
        return UNKNOWN;
    }
    public static TaskStateEnum valueOfKey(Integer key){
        for(TaskStateEnum taskStateEnum : TaskStateEnum .values()){
            if(taskStateEnum .getKey()==key){
                return taskStateEnum;
            }
        }
        return UNKNOWN;
    }
    private final Integer key;
    private final String description;

    TaskStateEnum(Integer key, String description) {
        this.key = key;
        this.description = description;
    }

    public Integer getKey() {
        return key;
    }
    public String getDescription() {
        return this.description;
    }
}
